package com.ax.action.system;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.ax.pojo.TabDown;
import com.ax.service.TabDownService;
import com.ax.utils.BaseAction;
import com.ax.utils.PageInfo;


@Controller("tabDownAction")
public class TabDownAction extends BaseAction {
	
	private TabDownService tabDownService;

	@Resource(name="tabDownService")
	public void setTabDownService(TabDownService tabDownService) {
		this.tabDownService = tabDownService;
	}
	
	private PageInfo page;
	public PageInfo getPage() {
		return page;
	}
	public void setPage(PageInfo page) {
		this.page = page;
	}
	public String findPage(){
		if (page==null) {
			page=new PageInfo();
		}
		page= tabDownService.findPageInfo(page.getCurPage(),"");
		return "lists";
	}
	public String save(){
		String dname=request.getParameter("dname");
		String dvalue=request.getParameter("dvalue");
		TabDown down=new TabDown(dname,dvalue);
		tabDownService.saveDown(down);
		return "listAction";
	}
	
	public String update(){
		String did=request.getParameter("did");
		String dname=request.getParameter("dname");
		String dvalue=request.getParameter("dvalue");
		TabDown down=new TabDown(dname,dvalue);
		down.setDid(Integer.parseInt(did));
		tabDownService.updateDown(down);
		return "listAction";
	}
	
	
	public String del(){
		String did=request.getParameter("did");
		TabDown tabDown=tabDownService.getDown(Integer.parseInt(did));
		tabDownService.delDown(tabDown);
		return "listAction";
	}

}
